package com.agileboot.domain.medicine.query;

import cn.hutool.core.util.StrUtil;
import com.agileboot.common.core.page.AbstractPageQuery;
import com.agileboot.domain.medicine.db.Medicine;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.StringUtils;

/**
 * @author lx
 */
@EqualsAndHashCode(callSuper = true)
@Data
@NoArgsConstructor
public class MedicineQuery extends AbstractPageQuery<Medicine> {
    //中文名字
    private String name;
    //别名
    private String nickName;
    //性味
    private String flavor;
    //性味
    private Integer status;

    @Override
    public QueryWrapper<Medicine> addQueryCondition() {
        QueryWrapper<Medicine> queryWrapper = new QueryWrapper<Medicine>()
                .like(StrUtil.isNotEmpty(name), "name", name)
                .like(StrUtil.isNotEmpty(nickName), "nick_name", nickName)
                .eq(status!=null,"status",status)
                .eq("deleted", 0)
                .like(StrUtil.isNotEmpty(flavor), "flavor", flavor);
        return queryWrapper;
    }
}
